import type { TreeNodeData } from 'element-plus';
import { request } from '../../request';

// get department list by page
export function fetchGetDeptInfoByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.Dept.DeptInfoQueryRecord>({
    url: '/rbac/dept_info/listByPage',
    method: 'post',
    data: params
  });
}

// get department info by id
export function fetchGetDeptInfoById(id: CommonType.IdType) {
  return request<Api.System.Dept.DeptInfoRecord>({
    url: '/rbac/dept_info/getDeptInfoById',
    method: 'get',
    params: {
      id
    }
  });
}

// get department tree data
export function fetchGetDeptTree() {
  return request<TreeNodeData>({
    url: '/rbac/dept_info/getDeptTree',
    method: 'get'
  });
}

// delete batch by ids
export function fetchDeleteDeptInfoBatchByIds(ids: CommonType.IdType[]) {
  return request({
    url: '/rbac/dept_info/deleteBatchByIds',
    method: 'post',
    data: ids
  });
}

// delete by id
export function fetchDeleteDeptInfoById(id: CommonType.IdType) {
  return request({
    url: '/rbac/dept_info/deleteById',
    method: 'post',
    params: {
      id
    }
  });
}

// save model
export function fetchDeptInfoSave(model: Api.System.Dept.DeptInfoFormModel) {
  return request({
    url: '/rbac/dept_info/save',
    method: 'post',
    data: model
  });
}

// get department trace text 当前部上级各层部门描述
export function fetchGetDeptTraceTextById(id: CommonType.IdType) {
  return request<string>({
    url: '/rbac/dept_info/getDeptTraceTextById',
    method: 'get',
    params: {
      id
    }
  });
}

// get list by page
export function fetchGetDeptTypeByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.Dept.DeptTypeQueryRecord>({
    url: '/rbac/dept_type/listByPage',
    method: 'post',
    data: params
  });
}

// get list all
export function fetchGetDeptTypeList() {
  return request<Api.System.Dept.DeptTypeRecord[]>({
    url: '/rbac/dept_type/listAll',
    method: 'get'
  });
}

// delete by id
export function fetchDeleteDeptTypeById(id: CommonType.IdType) {
  return request({
    url: '/rbac/dept_type/deleteById',
    method: 'post',
    params: {
      id
    }
  });
}

// save model
export function fetchDeptTypeSave(model: Api.System.Dept.DeptTypeFormModel) {
  return request({
    url: '/rbac/dept_type/save',
    method: 'post',
    data: model
  });
}
